{% extends "layout.html" %}
{% block content %}
<div class="container">
    <div class="row">
        <div class="col">
            <br />
            {{ pagination.links }}
        </div>
    </div>
    <div class="row">
        <div class="col">
            <h1>Recent requests</h1>
            <table class="table">
                <thead>
                    <tr>
                      <th>ID</th>
                      <th>Service</th>
                      <th>Email</th>
                      <th>Date</th>
                      <th>Status</th>
                  </tr>
              </thead>
              <tbody>
                  {% for request in requests %}
                    <tr {% if not request.checked %}class="table-warning"{% endif %}>
                        <td><a href="{{ url_for('admin_bp.view_request', request_id=request.id) }}">{{ request.id }}</a></td>
                        <td>{{ request.service.name }}</td>
                        <td>{{ request.email }}</td>
                        <td>{{ request.created_at | datetimeformat }}</td>
                        <td>{% if not request.notification_sent %}<i class="fa fa-envelope" aria-hidden="true" title="Notification not sent"></i>{% endif %}</td>
                    </tr>
                  {% endfor %}
              </tbody>
          </table>
        </div>
    </div>
    <div class="row">
        <div class="col">
            <br />
            {{ pagination.links }}
        </div>
    </div>
</div><!-- /.container -->
<script>
$(document).ready(function() {
    $('.table').dataTable( {
        paginate: false,
        "order": [[ 3, "desc" ]] // sort on date
    });
});
</script>
{% endblock %}
